#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "MenuBar.h"
#include "ProfileInfo.h"

#include <QtCore/QTimer>
#include <QtGui/QMainWindow>
#include <QtGui/QCloseEvent>
#include <QtGui/QTextEdit>
#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QWidget>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include <QtGui/QTextDocument>
#include <QtGui/QTableWidget>

#include <string>

class Controller;


class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
    // Constructor & Destructor
    
    MainWindow(char* title, Controller* parent);
    virtual ~MainWindow();
    
    //// Memberfunctions
    
    void initialize(char* title);
    void cleanup();

	void startTimers();
    
	void addMessage(QString nick, QString message);
	void addContact(QString nick, bool online);
	void changeContactStatus(QString nick, bool status);
	void setInfo(ProfileInfo & info);
	std::string getSelectedNickName();

	void showWarningDialog(QString title, QString message);
	void showInformationDialog(QString title, QString message);

    // Callbacks
    
    virtual void closeEvent(QCloseEvent* evt);
    
public:
    // Menubar
    
    MenuBar* m_menuBar;
    
    // Layouts
    
    QVBoxLayout m_mainLayout;
    QHBoxLayout m_inputLayout;
    QHBoxLayout m_infoLayout;
    
    // Widgets
    
    QTableWidget* m_contactList;
    QTextEdit* m_infoBox;
	QTextDocument* m_textDocument;
    
    QTextEdit* m_chatBox;
    
    QTextEdit* m_inputBox;
    QPushButton* m_sendButton; 
    
    // Scroll Area's
    
    QScrollArea m_chatScrollArea;
    QScrollArea m_inputScrollArea;
    QScrollArea m_contactScrollArea;
    QScrollArea m_infoScrollArea;

	// Timer

	QTimer* m_sessionTimer;
	QTimer* m_statusTimer;

private:
	// Memberfunctions

	void createMenuBar();

	// Membervariables

	Controller* m_owner;

public slots:
	void sentMessage();
	void sessionTimeout();
	void statusTimeout();
};

#endif

